package com.whl215.kit.adapter.wrap


/**
 * author： happiness
 * date： 2021/2/24
 * description：
 */
abstract class GrapeNodeWrapper : GrapeItemWrapper() {

    var isExpend = false //标记分组是否展开
    var groupId: String = "" // 当数据作为成员时 所归属的分组id
    private val wrapperList = mutableListOf<GrapeNodeWrapper>()

    fun getChildren(): MutableList<GrapeNodeWrapper> {
        if (wrapperList.isEmpty()) {
            wrapperList.addAll(convertDataToWrapper())
        }
        return wrapperList
    }

    open fun convertDataToWrapper(): MutableList<GrapeNodeWrapper>{
        return mutableListOf()
    }

    abstract fun getItemId(): String

    open fun addChild(wrapper: GrapeNodeWrapper) {
        if (wrapperList.isNotEmpty())
            wrapperList.add(wrapper)
    }

    open fun removeChild(wrapper: GrapeNodeWrapper) {
        if (wrapperList.isNotEmpty())
            wrapperList.remove(wrapper)
    }


}